#include <REGX52.H>
#include "DELAY.h"
#include "KEY.h"
#include "TIMER0.h"
#include "NIXIE.h"

sbit DA=P2^1;

unsigned char Counter,Compare;//计数值和比较值，用于输出PWM
unsigned char i;

void main()
{
	Timer0_Init();
	while(1)
	{
		for(i=0;i<100;i++)//这里PWM的取值范围是0~100
		{
			Compare=i;
			Delay(10);
		}
		for(i=100;i>0;i--)
		{
			Compare=i;
			Delay(10);
		}//呼吸灯
	}
}

//每隔100us进来一次
void Timer0_Routine() interrupt 1
{
	TL0 = 0x9C;				//设置定时初始值
	TH0 = 0xFF;				//设置定时初始值
	Counter++;
	Counter%=100;//Counter范围是1~100,100*100us=10ms,T=10ms
	if(Counter<Compare)DA=1;
	else DA=0;
}